//
//  TBRRecevePlaneMessagePickerC.m
//  TBRentClient
//
//  Created by tonbright on 2018/5/21.
//  Copyright © 2018年 tonbright. All rights reserved.
//

#import "TBRRecevePlaneMessagePickerC.h"

@interface TBRRecevePlaneMessagePickerC ()<UIPickerViewDataSource,UIPickerViewDelegate>




//是否选中第一行呢
@end

@implementation TBRRecevePlaneMessagePickerC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.pickerView.dataSource = self;
    self.pickerView.delegate = self;
    [self.pickerView selectRow:0 inComponent:0 animated:NO];
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
    return 1;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
    return self.dateArray.count;
}

- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component {
    return 40;
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
    TBRGetPlaneMessageModel *planeMessageModel = self.dateArray[row];
    NSString *str = [NSString stringWithFormat:@"%@-%@ %@-%@",planeMessageModel.fromCityName,planeMessageModel.toCityName,planeMessageModel.planTime,planeMessageModel.planArriveTime];
    return str;
}



- (IBAction)cancleBtnClick:(UIButton *)sender {
    
    if (sender.tag == 10) {
        
        if (self.pickerViewCancleBtnBlock) {
            self.pickerViewCancleBtnBlock();
        }
    }else if (sender.tag == 20) {
        NSInteger dateIndex = [self.pickerView selectedRowInComponent:0];
        if (self.pickerViewSureBtnBlock) {
            self.pickerViewSureBtnBlock(self.dateArray[dateIndex]);
        }
    }
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    if (self.pickerViewCancleBtnBlock) {
        self.pickerViewCancleBtnBlock();
    }
}

@end
